using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_View {
		#region Fields
		private int iD;
		private string name;
		private string description;
		private string detail;
		private int cityID;
		private int distinctId;
		private int position;
		private int lanuageId;
		private decimal viewPrice;
		private int type_id;
		private string type;
		private int star;
		private int rating;
		private string address;
		private string telephone;
		private string fax;
		private string openTime;
		private int unitPrice;
		private string overView;
		private string uRL;
		private string locCode;
		private string imageURL;
		private double lat;
		private double lng;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_View class.
		/// </summary>
		public TF_View() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_View class.
		/// </summary>
		public TF_View(string name, string description, string detail, int cityID, int distinctId, int position, int lanuageId, decimal viewPrice, int type_id, string type, int star, int rating, string address, string telephone, string fax, string openTime, int unitPrice, string overView, string uRL, string locCode, string imageURL, double lat, double lng) {
			this.name = name;
			this.description = description;
			this.detail = detail;
			this.cityID = cityID;
			this.distinctId = distinctId;
			this.position = position;
			this.lanuageId = lanuageId;
			this.viewPrice = viewPrice;
			this.type_id = type_id;
			this.type = type;
			this.star = star;
			this.rating = rating;
			this.address = address;
			this.telephone = telephone;
			this.fax = fax;
			this.openTime = openTime;
			this.unitPrice = unitPrice;
			this.overView = overView;
			this.uRL = uRL;
			this.locCode = locCode;
			this.imageURL = imageURL;
			this.lat = lat;
			this.lng = lng;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_View class.
		/// </summary>
		public TF_View(int iD, string name, string description, string detail, int cityID, int distinctId, int position, int lanuageId, decimal viewPrice, int type_id, string type, int star, int rating, string address, string telephone, string fax, string openTime, int unitPrice, string overView, string uRL, string locCode, string imageURL, double lat, double lng) {
			this.iD = iD;
			this.name = name;
			this.description = description;
			this.detail = detail;
			this.cityID = cityID;
			this.distinctId = distinctId;
			this.position = position;
			this.lanuageId = lanuageId;
			this.viewPrice = viewPrice;
			this.type_id = type_id;
			this.type = type;
			this.star = star;
			this.rating = rating;
			this.address = address;
			this.telephone = telephone;
			this.fax = fax;
			this.openTime = openTime;
			this.unitPrice = unitPrice;
			this.overView = overView;
			this.uRL = uRL;
			this.locCode = locCode;
			this.imageURL = imageURL;
			this.lat = lat;
			this.lng = lng;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the ID value.
		/// </summary>
		public int ID {
			get { return iD; }
			set { iD = value; }
		}
		
		/// <summary>
		/// Gets or sets the Name value.
		/// </summary>
		public string Name {
			get { return name; }
			set { name = value; }
		}
		
		/// <summary>
		/// Gets or sets the Description value.
		/// </summary>
		public string Description {
			get { return description; }
			set { description = value; }
		}
		
		/// <summary>
		/// Gets or sets the Detail value.
		/// </summary>
		public string Detail {
			get { return detail; }
			set { detail = value; }
		}
		
		/// <summary>
		/// Gets or sets the CityID value.
		/// </summary>
		public int CityID {
			get { return cityID; }
			set { cityID = value; }
		}
		
		/// <summary>
		/// Gets or sets the DistinctId value.
		/// </summary>
		public int DistinctId {
			get { return distinctId; }
			set { distinctId = value; }
		}
		
		/// <summary>
		/// Gets or sets the Position value.
		/// </summary>
		public int Position {
			get { return position; }
			set { position = value; }
		}
		
		/// <summary>
		/// Gets or sets the LanuageId value.
		/// </summary>
		public int LanuageId {
			get { return lanuageId; }
			set { lanuageId = value; }
		}
		
		/// <summary>
		/// Gets or sets the ViewPrice value.
		/// </summary>
		public decimal ViewPrice {
			get { return viewPrice; }
			set { viewPrice = value; }
		}
		
		/// <summary>
		/// Gets or sets the Type_id value.
		/// </summary>
		public int Type_id {
			get { return type_id; }
			set { type_id = value; }
		}
		
		/// <summary>
		/// Gets or sets the Type value.
		/// </summary>
		public string Type {
			get { return type; }
			set { type = value; }
		}
		
		/// <summary>
		/// Gets or sets the Star value.
		/// </summary>
		public int Star {
			get { return star; }
			set { star = value; }
		}
		
		/// <summary>
		/// Gets or sets the Rating value.
		/// </summary>
		public int Rating {
			get { return rating; }
			set { rating = value; }
		}
		
		/// <summary>
		/// Gets or sets the Address value.
		/// </summary>
		public string Address {
			get { return address; }
			set { address = value; }
		}
		
		/// <summary>
		/// Gets or sets the Telephone value.
		/// </summary>
		public string Telephone {
			get { return telephone; }
			set { telephone = value; }
		}
		
		/// <summary>
		/// Gets or sets the Fax value.
		/// </summary>
		public string Fax {
			get { return fax; }
			set { fax = value; }
		}
		
		/// <summary>
		/// Gets or sets the OpenTime value.
		/// </summary>
		public string OpenTime {
			get { return openTime; }
			set { openTime = value; }
		}
		
		/// <summary>
		/// Gets or sets the UnitPrice value.
		/// </summary>
		public int UnitPrice {
			get { return unitPrice; }
			set { unitPrice = value; }
		}
		
		/// <summary>
		/// Gets or sets the OverView value.
		/// </summary>
		public string OverView {
			get { return overView; }
			set { overView = value; }
		}
		
		/// <summary>
		/// Gets or sets the URL value.
		/// </summary>
		public string URL {
			get { return uRL; }
			set { uRL = value; }
		}
		
		/// <summary>
		/// Gets or sets the LocCode value.
		/// </summary>
		public string LocCode {
			get { return locCode; }
			set { locCode = value; }
		}
		
		/// <summary>
		/// Gets or sets the ImageURL value.
		/// </summary>
		public string ImageURL {
			get { return imageURL; }
			set { imageURL = value; }
		}
		
		/// <summary>
		/// Gets or sets the Lat value.
		/// </summary>
		public double Lat {
			get { return lat; }
			set { lat = value; }
		}
		
		/// <summary>
		/// Gets or sets the Lng value.
		/// </summary>
		public double Lng {
			get { return lng; }
			set { lng = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_View table.
		/// </summary>
		public void Insert() {
			iD = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_ViewInsert", name, description, detail, cityID, distinctId, position, lanuageId, viewPrice, type_id, type, star, rating, address, telephone, fax, openTime, unitPrice, overView, uRL, locCode, imageURL, lat, lng));
		}
		
		/// <summary>
		/// Updates a record in the TF_View table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_ViewUpdate", iD, name, description, detail, cityID, distinctId, position, lanuageId, viewPrice, type_id, type, star, rating, address, telephone, fax, openTime, unitPrice, overView, uRL, locCode, imageURL, lat, lng);
		}
		
		/// <summary>
		/// Deletes a record from the TF_View table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_ViewDelete", iD);
		}
		
		/// <summary>
		/// Selects a single record from the TF_View table.
		/// </summary>
		public static TF_View Select(int iD) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_ViewSelect", iD)) {
				if (dataReader.Read()) {
					return MakeTF_View(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_View table.
		/// </summary>
		public static List<TF_View> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_ViewSelectAll")) {
				List<TF_View> tF_ViewList = new List<TF_View>();
				while (dataReader.Read()) {
					TF_View tF_View = MakeTF_View(dataReader);
					tF_ViewList.Add(tF_View);
				}
				return tF_ViewList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_View class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_View MakeTF_View(SqlDataReader dataReader) {
			TF_View tF_View = new TF_View();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_View.ID = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_View.Name = dataReader.GetString(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_View.Description = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_View.Detail = dataReader.GetString(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_View.CityID = dataReader.GetInt32(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_View.DistinctId = dataReader.GetInt32(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_View.Position = dataReader.GetInt32(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_View.LanuageId = dataReader.GetInt32(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				tF_View.ViewPrice = dataReader.GetDecimal(8);
			}
			if (dataReader.IsDBNull(9) == false) {
				tF_View.Type_id = dataReader.GetInt32(9);
			}
			if (dataReader.IsDBNull(10) == false) {
				tF_View.Type = dataReader.GetString(10);
			}
			if (dataReader.IsDBNull(11) == false) {
				tF_View.Star = dataReader.GetInt32(11);
			}
			if (dataReader.IsDBNull(12) == false) {
				tF_View.Rating = dataReader.GetInt32(12);
			}
			if (dataReader.IsDBNull(13) == false) {
				tF_View.Address = dataReader.GetString(13);
			}
			if (dataReader.IsDBNull(14) == false) {
				tF_View.Telephone = dataReader.GetString(14);
			}
			if (dataReader.IsDBNull(15) == false) {
				tF_View.Fax = dataReader.GetString(15);
			}
			if (dataReader.IsDBNull(16) == false) {
				tF_View.OpenTime = dataReader.GetString(16);
			}
			if (dataReader.IsDBNull(17) == false) {
				tF_View.UnitPrice = dataReader.GetInt32(17);
			}
			if (dataReader.IsDBNull(18) == false) {
				tF_View.OverView = dataReader.GetString(18);
			}
			if (dataReader.IsDBNull(19) == false) {
				tF_View.URL = dataReader.GetString(19);
			}
			if (dataReader.IsDBNull(20) == false) {
				tF_View.LocCode = dataReader.GetString(20);
			}
			if (dataReader.IsDBNull(21) == false) {
				tF_View.ImageURL = dataReader.GetString(21);
			}
			if (dataReader.IsDBNull(22) == false) {
				tF_View.Lat = dataReader.GetDouble(22);
			}
			if (dataReader.IsDBNull(23) == false) {
				tF_View.Lng = dataReader.GetDouble(23);
			}

			return tF_View;
		}
		#endregion
	}
}
